#include "UnitTest++.h"
#include "ZipValidator.h"

TEST(ShouldReturnTrueGivenAFileWithZipExtension)
{
    ZipValidator validator;
    bool actual = validator.validateZipPath("file.zip");
    bool expected = 1;
    CHECK(actual == expected);
}

TEST(ShouldReturnFalseGivenAFileWithNoExtension)
{
    ZipValidator validator;
    bool actual = validator.validateZipPath("zip");
    bool expected = 0;
    CHECK(actual == expected);
}

TEST(ShouldReturnTrueGivenAFileWithZipExtensionZipx)
{
    ZipValidator validator;
    bool actual = validator.validateZipPath("file.zipx");
    bool expected = 1;
    CHECK(actual == expected);
}

TEST(ShouldReturnFalseGivenAFileWithoutZipExtension)
{
    ZipValidator validator;
    bool actual = validator.validateZipPath("file.txt");
    bool expected = 0;
    CHECK(actual == expected);
}

TEST(ShouldReturnTrueGivenAFileWithThePkSignature)
{
    ZipValidator validator;
    bool actual = validator.validateZipFileSignature("resources/file.zip");
    bool expected = 1;
    CHECK(actual == expected);
}

TEST(ShouldReturnFalseGivenANonZipFile)
{
    ZipValidator validator;
    bool actual = validator.validateZipFileSignature("resources/nonzip.zip");
    bool expected = 0;
    CHECK(actual == expected);
}

TEST(GivenAZipFileShouldValidateTheExtensionAndSignature)
{
    ZipValidator validator;
    ErrorCode actual = validator.validateZip("resources/file.zip");
    ErrorCode expected = VALID_ZIP_FILE;
    CHECK(actual == expected);
}


TEST(GivenANonZipFileShouldntValidateTheExtension)
{
    ZipValidator validator;
    ErrorCode actual = validator.validateZip("file");
    ErrorCode expected = INVALID_EXTENSION;
    CHECK(actual == expected);
}

TEST(GivenANonZipFileShouldntValidateTheSignature)
{
    ZipValidator validator;
    ErrorCode actual = validator.validateZip("resources/nonzip.zip");
    ErrorCode expected = NOT_A_ZIP_FILE;
    CHECK(actual == expected);
}